package jp.joogoo.web.meta;

//@javax.annotation.Generated(value = { "slim3-gen", "@VERSION@" }, date = "2010-11-03 21:04:21")
/** */
public final class M_joogooMeta extends org.slim3.datastore.ModelMeta<jp.joogoo.web.model.M_joogoo> {

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<jp.joogoo.web.model.M_joogoo, java.lang.Integer> interval = new org.slim3.datastore.CoreAttributeMeta<jp.joogoo.web.model.M_joogoo, java.lang.Integer>(this, "interval", "interval", int.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<jp.joogoo.web.model.M_joogoo, com.google.appengine.api.datastore.Key> key = new org.slim3.datastore.CoreAttributeMeta<jp.joogoo.web.model.M_joogoo, com.google.appengine.api.datastore.Key>(this, "__key__", "key", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.ModelRefAttributeMeta<jp.joogoo.web.model.M_joogoo, org.slim3.datastore.ModelRef<jp.joogoo.web.model.M_service>, jp.joogoo.web.model.M_service> mServiceRef = new org.slim3.datastore.ModelRefAttributeMeta<jp.joogoo.web.model.M_joogoo, org.slim3.datastore.ModelRef<jp.joogoo.web.model.M_service>, jp.joogoo.web.model.M_service>(this, "mServiceRef", "mServiceRef", org.slim3.datastore.ModelRef.class, jp.joogoo.web.model.M_service.class);

    /** */
    public final org.slim3.datastore.StringAttributeMeta<jp.joogoo.web.model.M_joogoo> token = new org.slim3.datastore.StringAttributeMeta<jp.joogoo.web.model.M_joogoo>(this, "token", "token");

    /** */
    public final org.slim3.datastore.StringAttributeMeta<jp.joogoo.web.model.M_joogoo> userId = new org.slim3.datastore.StringAttributeMeta<jp.joogoo.web.model.M_joogoo>(this, "userId", "userId");

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<jp.joogoo.web.model.M_joogoo, java.lang.Long> version = new org.slim3.datastore.CoreAttributeMeta<jp.joogoo.web.model.M_joogoo, java.lang.Long>(this, "version", "version", java.lang.Long.class);

    private static final M_joogooMeta slim3_singleton = new M_joogooMeta();

    /**
     * @return the singleton
     */
    public static M_joogooMeta get() {
       return slim3_singleton;
    }

    /** */
    public M_joogooMeta() {
        super("M_joogoo", jp.joogoo.web.model.M_joogoo.class);
    }

    @Override
    public jp.joogoo.web.model.M_joogoo entityToModel(com.google.appengine.api.datastore.Entity entity) {
        jp.joogoo.web.model.M_joogoo model = new jp.joogoo.web.model.M_joogoo();
        model.setInterval(longToPrimitiveInt((java.lang.Long) entity.getProperty("interval")));
        model.setKey(entity.getKey());
        if (model.getMServiceRef() == null) {
            throw new NullPointerException("The property(mServiceRef) is null.");
        }
        model.getMServiceRef().setKey((com.google.appengine.api.datastore.Key) entity.getProperty("mServiceRef"));
        model.setToken((java.lang.String) entity.getProperty("token"));
        model.setUserId((java.lang.String) entity.getProperty("userId"));
        model.setVersion((java.lang.Long) entity.getProperty("version"));
        return model;
    }

    @Override
    public com.google.appengine.api.datastore.Entity modelToEntity(java.lang.Object model) {
        jp.joogoo.web.model.M_joogoo m = (jp.joogoo.web.model.M_joogoo) model;
        com.google.appengine.api.datastore.Entity entity = null;
        if (m.getKey() != null) {
            entity = new com.google.appengine.api.datastore.Entity(m.getKey());
        } else {
            entity = new com.google.appengine.api.datastore.Entity(kind);
        }
        entity.setProperty("interval", m.getInterval());
        if (m.getMServiceRef() == null) {
            throw new NullPointerException("The property(mServiceRef) must not be null.");
        }
        entity.setProperty("mServiceRef", org.slim3.datastore.ModelMeta.assignKeyIfNecessary(m.getMServiceRef().getModelMeta(), m.getMServiceRef().getModel()));
        entity.setProperty("token", m.getToken());
        entity.setProperty("userId", m.getUserId());
        entity.setProperty("version", m.getVersion());
        entity.setProperty("slim3.schemaVersion", 1);
        return entity;
    }

    @Override
    protected com.google.appengine.api.datastore.Key getKey(Object model) {
        jp.joogoo.web.model.M_joogoo m = (jp.joogoo.web.model.M_joogoo) model;
        return m.getKey();
    }

    @Override
    protected void setKey(Object model, com.google.appengine.api.datastore.Key key) {
        validateKey(key);
        jp.joogoo.web.model.M_joogoo m = (jp.joogoo.web.model.M_joogoo) model;
        m.setKey(key);
    }

    @Override
    protected long getVersion(Object model) {
        jp.joogoo.web.model.M_joogoo m = (jp.joogoo.web.model.M_joogoo) model;
        return m.getVersion() != null ? m.getVersion().longValue() : 0L;
    }

    @Override
    protected void incrementVersion(Object model) {
        jp.joogoo.web.model.M_joogoo m = (jp.joogoo.web.model.M_joogoo) model;
        long version = m.getVersion() != null ? m.getVersion().longValue() : 0L;
        m.setVersion(Long.valueOf(version + 1L));
    }

    @Override
    protected void prePut(Object model) {
        assignKeyIfNecessary(model);
        incrementVersion(model);
    }

    @Override
    public String getSchemaVersionName() {
        return "slim3.schemaVersion";
    }

    @Override
    public String getClassHierarchyListName() {
        return "slim3.classHierarchyList";
    }

}